package com.lehecai.core.type.pstation;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by He Wang on 14-7-22.
 */
public class PstationTaskStatus extends IntegerBeanLabelItem {

	private static final long serialVersionUID = -163363436423392807L;

	private static final Logger logger = LoggerFactory.getLogger(PstationTaskStatus.class.getName());
	private static List<PstationTaskStatus> items = new ArrayList<PstationTaskStatus>();
	private static List<PstationTaskStatus> queryItems = new ArrayList<PstationTaskStatus>();

	protected PstationTaskStatus(String name, int value, boolean queryOnly) {
		super(PstationTaskStatus.class.getName(), name, value);

		queryItems.add(this);
		if (!queryOnly) {
			items.add(this);
		}
	}

	protected PstationTaskStatus(String name, int value) {
		this(name, value, false);
	}

	public static PstationTaskStatus getItem(int value){
		try {
			return (PstationTaskStatus) PstationTaskStatus.getResult(PstationTaskStatus.class.getName(), value);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}

	public static List<PstationTaskStatus> getItems() {
		return items;
	}

	public static List<PstationTaskStatus> getItemsForQuery() {
		return queryItems;
	}

	public static final PstationTaskStatus ALL = new PstationTaskStatus("全部", 0, true);

	public static final PstationTaskStatus CREATED = new PstationTaskStatus("已创建", 1);
	public static final PstationTaskStatus SENT = new PstationTaskStatus("已发送至队列", 2);
	public static final PstationTaskStatus RECEIVED = new PstationTaskStatus("已从队列接收", 3);
	public static final PstationTaskStatus EXECUTING = new PstationTaskStatus("开始执行", 4);
	public static final PstationTaskStatus DONE = new PstationTaskStatus("已完成", 5);
	public static final PstationTaskStatus OBSOLETED = new PstationTaskStatus("已作废", 6);
}
